//
//  sQhlIkJLCFMineInterestViewControllergApCgY.m
//  qcb_ios
//
//  Created by Ji on 2018/9/3.
//  Copyright © 2018年 ski. All rights reserved.
//

#import "sQhlIkJLCFMineInterestViewControllergApCgY.h"
#import "sHkPtEJLCFMineRequestozAYZs.h"
#import "ijRDamJLCFMineInterestCelloYEtNj.h"

@interface sQhlIkJLCFMineInterestViewControllergApCgY ()
{
    NSInteger _pageNumber;
}

@property (nonatomic, strong) NSMutableArray *CeaQRNinterestArrIUMyEJ;


@end

@implementation sQhlIkJLCFMineInterestViewControllergApCgY

- (NSMutableArray *)CeaQRNinterestArrIUMyEJ
{
    if (!_CeaQRNinterestArrIUMyEJ) {
        _CeaQRNinterestArrIUMyEJ = [NSMutableArray array];
    }
    return _CeaQRNinterestArrIUMyEJ;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = QTZ_Gray237;
    self.tableView.frame = CGRectMake(0, NAVBAR_HEIGHT + 50, FULL_WIDTH, FULL_HEIGHT - NAVBAR_HEIGHT - 50 - (IPHONEX ? 24 : 0));
    
    [self loadData];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)loadData
{
    
    [self.CeaQRNinterestArrIUMyEJ removeAllObjects];
    _pageNumber = 1;
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setSafeObject:@"2" forKey:@"hbtype"];
    [params setSafeObject:@(_pageNumber) forKey:@"page"];
    
    [sHkPtEJLCFMineRequestozAYZs welfareWith:params loadingInView:self.view success:^(YvmmJAJLCFXNbZWBMineWelfareResultModeleKVPRGMnuDpo *welfare) {
        [self hideNoMoreDataNotice];
        if (welfare.data.count > 0) {
            [self.CeaQRNinterestArrIUMyEJ addObjectsFromSafeArray:welfare.data];
        } else {
            [self showNoMoreDataNotice:@"没有更多了"];
        }
        [self.tableView reloadData];
        [self endRefresh];
    } failure:^(NSString *error) {
        [self endRefresh];
        [self showNotice:error];
    }];
    
}

- (void)loadMoreData
{
    _pageNumber ++;
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setSafeObject:@"2" forKey:@"hbtype"];
    [params setSafeObject:@(_pageNumber) forKey:@"page"];
    
    [sHkPtEJLCFMineRequestozAYZs welfareWith:params loadingInView:self.view success:^(YvmmJAJLCFXNbZWBMineWelfareResultModeleKVPRGMnuDpo *welfare) {
        [self hideNoMoreDataNotice];
        if (welfare.data.count > 0) {
            [self.CeaQRNinterestArrIUMyEJ addObjectsFromSafeArray:welfare.data];
        } else {
            self.tableView.mj_footer.hidden = YES;
        }
        [self.tableView reloadData];
        [self endLoadMore];
    } failure:^(NSString *error) {
        [self endLoadMore];
        [self showNotice:error];
    }];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.CeaQRNinterestArrIUMyEJ.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 90;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *rRHNlxheaderViewfJQeRl = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, 15)];
    rRHNlxheaderViewfJQeRl.backgroundColor = [UIColor clearColor];
    return rRHNlxheaderViewfJQeRl;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 15;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ijRDamJLCFMineInterestCelloYEtNj *cell = [ijRDamJLCFMineInterestCelloYEtNj dequeueReusableCellForTableView:tableView];
    cell.welfare = [self.CeaQRNinterestArrIUMyEJ safeObjectAtIndex:indexPath.section];
    [cell reloadData];
    return cell;
}


@end
